////
////  CommonPay.swift
////  Screen
////
////  通用支付逻辑
////
////  Created by Season02 on 9/27/16.
////  Copyright © 2016 alex.chih. All rights reserved.
////
//
//import Foundation
//import SwiftHTTP
//
//@objc(CommonPay)
//class CommonPay: NSObject
//{
//    @objc
//    enum Result:Int
//    {
//        case OK, FAILED
//    }
//    
//    @objc
//    static let UrlOfPay = SRef.URL(.unionAppPay)// "http://182.92.131.86:8099/gmhy/unionAppPay";
////    static let UrlOfPay = "http://192.168.3.117:8088/gmhy/unionAppPay"
//    
//    @objc
//    static let UrlOfCheck = SRef.URL(.checkPayStatus)// "http://182.92.131.86:8099/gmhy/appPayCheck";
////    static let UrlOfCheck = "http://192.168.3.117:8088/gmhy/appPayCheck"
//    
//    //@objc(UnionPay:(NSString*)type pid:(NSString*)pid view:(UIViewController*)view)
//    static func UnionPay(_ type:NSString, id:NSString, view:UIViewController, callback:@escaping (Result) -> Void)
//    {
//        let userId = SettingDone.getUserId()
//        
//        let url = UrlOfPay
//        
//        let params = ["userId": userId, "zftype": type, "orderType": id] as [String : Any]
//        
//        //print("params: \(params)")
//        
//        do
//        {
//            let opt = try HTTP.POST(NaFilter.requestDic(url: url, par: nil), parameters: params)
//            opt.start
//                { response in
//                    if let err = response.error
//                    {
//                        print("error: \(err.localizedDescription)")
//                        
//                        callback(Result.FAILED)
//                        return//also notify app of failure as needed
//                    }
//                    
//                    //print("opt finished: \(response.description)")
//                    
//                    let data = response.data
//                    
//                    let dic = try! JSONSerialization.jsonObject(with: data,
//                        options: JSONSerialization.ReadingOptions.mutableContainers) as! NSMutableDictionary
//                    
//                    if "success" != dic.value(forKey: "status") as? String
//                    {
//                        callback(Result.FAILED)
//                        return
//                    }
//                    
//                    if "alipay" == type
//                    {
//                        let signedOrder = dic.value(forKey: "readyToPay") as! String
//                        
//                        ThirdPartAlipay.setupView(view)
//                        ThirdPartAlipay.setBuyHistoryId(dic.value(forKey: "buyhistoryid") as! String)
//                        ThirdPartAlipay.alipay(signedOrder)
//                        
//                        callback(Result.OK)//发起支付ok
//                    }
//                    else if "WeichatPay" == type
//                    {
//                        let par = dic.value(forKey: "readyToPay") as! NSDictionary
//                        
//                        ThirdPartWechat.setupView(view)
//                        ThirdPartWechat.setBuyHistoryId(dic.value(forKey: "buyhistoryid") as! String)
//                        ThirdPartWechat.risePay(par as! [AnyHashable: Any] )
//                        
//                        callback(Result.OK)//发起支付ok
//                    }
//                    
//            }
//        }
//        catch let error
//        {
//            print("got an error creating the request: \(error)")
//            callback(Result.FAILED)
//        }
//    }
//    
//    
//}
